module.exports  = {
    data(){
        return {
            //设置默认的分享参数
            share: {
                title: `睿职`, // 分享标题
                path: '', // 默认为当前页面路径
                desc: '最具人气的小程序开发联盟!',
                content:''
            }
        }
    },
    onShareAppMessage(res) {
        let pages = getCurrentPages()    //获取加载的页面
        let currentPage = pages[pages.length-1]    //获取当前页面的对象
        let options = currentPage.options    //如果要获取url中所带的参数可以查看options
        let url= currentPage.route+'?';
        Object.keys(options).forEach((key)=>{
            url +=key+'='+options[key]+'&'
        })
        url+='detail=1'
        console.log(url)
        return {
            title:this.share.title,
            path: url,
            imageUrl:this.share.imageUrl,
            desc:this.share.desc,
            content:this.share.content,
            success(res){
                uni.showToast({
                    title:'分享成功'
                })
            },
            fail(res){
                uni.showToast({
                    title:'分享失败',
                    icon:'none'
                })
            }
        }
    },
    onShareTimeline(res) {
        return {
            title:this.share.title,
            path:this.share.path,
            imageUrl:this.share.imageUrl,
            desc:this.share.desc,
            content:this.share.content,
            success(res){
                uni.showToast({
                    title:'分享成功'
                })
            },
            fail(res){
                uni.showToast({
                    title:'分享失败',
                    icon:'none'
                })
            }
        }
    }
}